/*
 * Copyright (C) 2019
 * <tang-haifeng@foxmail.com> <pengren.mcu@qq.com>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 *
 */

#include <common.h>
#include <clk.h>
#include <led.h>
#include <pci.h>

#include <asm/io.h>
#include <asm/gpio.h>

#include <mach/ls2k.h>

DECLARE_GLOBAL_DATA_PTR;


#ifndef NAND_LS2K_DMACHAN
#define NAND_LS2K_DMACHAN 0
#endif
#ifndef SDIO_LS2K_DMACHAN
#define SDIO_LS2K_DMACHAN 4
#endif

/* 设置设备使用的apb dma通道 */
static void ls2x_set_apbdma(void)
{
	u32 val;
	void __iomem *apb_dma_cfg = ioremap(LS2X_APB_DMA_CFG, 1);

	val = (NAND_LS2K_DMACHAN<<0) |
		(1<<3) | (2<<6) | (1<<9) | (2<<12) | (SDIO_LS2K_DMACHAN<<15) | (1<<18) | (3<<21);
	__raw_writel(val, apb_dma_cfg);
}

int board_early_init_f(void)
{
	ls2x_set_apbdma();

	return 0;
}
